import java.util.Random;
import java.util.Scanner;

/**
 * switch实现石头/剪子/布并判断胜负
 */
public class RockPaper {
        static int a = 0;  //记录胜局
        static int b = 0;  //记录平局

        public static void main(String[] args) {
            System.out.println("--------------剪刀石头布小游戏---------------");
            System.out.println("1：剪刀、2：石头、3：布");
            Scanner sc = new Scanner(System.in);
            // 进行5轮游戏
            for (int i = 1; i <= 5; ++i) {
                System.out.println("Round: " + i);
                System.out.print("你出的是：");
                String choose = sc.next();
                int num = new Random().nextInt(3) + 1;
                if (choose.equals("剪刀")) {
                    if (num == 1) {
                        System.out.println("电脑出的是：剪刀");
                        System.out.println("平局");
                        b++;
                    } else if (num == 2) {
                        System.out.println("电脑出的是：石头");
                        System.out.println("You lose!");
                    } else {
                        System.out.println("电脑出的是：布");
                        System.out.println("You win!");
                        a++;
                    }
                } else if (choose.equals("石头")) {
                    if (num == 1) {
                        System.out.println("电脑出的是：剪刀");
                        System.out.println("You win!");
                        a++;
                    } else if (num == 2) {
                        System.out.println("电脑出的是：石头");
                        System.out.println("平局");
                        b++;
                    } else {
                        System.out.println("电脑出的是：布");
                        System.out.println("You lose!");
                    }
                } else {
                    if (num == 1) {
                        System.out.println("电脑出的是：剪刀");
                        System.out.println("You lose!");
                    } else if (num == 2) {
                        System.out.println("电脑出的是：石头");
                        System.out.println("You win!");
                        a++;
                    } else {
                        System.out.println("电脑出的是：布");
                        System.out.println("平句");
                        b++;
                    }
                }
            }
            int c = 5 - a - b;
            System.out.println("电脑赢了" + c + "局");
            System.out.println("你总共赢了" + a + "局，" + "平了" + b + "局");
            if (a == c) {
                System.out.println("结果为平局");
            } else if (a > b) {
                System.out.println("结果你赢了！");
            } else System.out.println("结果你输了！");
        }
    }


